#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main()
{
	printf("begining...\n");
	pid_t id = fork();
	
	if(id == 0)
	{
		while(1)
		{
			printf("I am child... PID: %d, PPID: %d\n", getpid(), getppid());
			sleep(1);
		}
	}
	else if(id > 0)
	{
		int count = 5;
		while(count)
		{
			printf("I am parent... PID: %d, PPID: %d, count: %d\n", getpid(), getppid(), count);
			sleep(1);
			count--;
		}
		printf("parent ending...\n");
		exit(1);
	}
	else
	{}
	
	return 0;

}

/*int main()
{
	printf("begining...\n");
	pid_t id = fork();
	
	if(id == 0) //child
	{
		int count = 5;
		while(count)
		{	
			printf("I am child...PID:%d, PPID:%d, count: %d\n", getpid(), getppid(), count);
			sleep(1);
			count--;
		}
		
		printf("child quit...\n");
		exit(1);
	}
	else if(id > 0) //parent
	{
		while(1)
		{
			printf("I am parent...PID:%d, PPID:%d\n", getpid(), getppid());
			sleep(1);
		}
	}
	else //error
	{}
	return 0;
}*/


/*int main()
{
	printf("hello Linux!!!\n");
	sleep(100);
	
	return 0;
}*/
